<template>
  <header class="ui_border_b">
      <span v-if="back" @click="historyBack()" class="left"><i class="icon icon-back"></i></span>
      <p>{{title}}</p>
      <slot></slot>
  </header>
</template>

<script>
export default {
  name: "myHeader",
  props: ["title", "back"],
  methods: {
    historyBack() {
      history.back();
    }
  }
};
</script>

<style lang="scss">
$height: 3rem;
header {
  position: absolute;
  top: 0;
  width: 100%;
  height: $height;
  padding: 0 $height;
  background: #fff;
  z-index: 100;
  .left,
  .right {
    display: block;
    width: $height;
    height: $height;
    position: absolute;
    top: 0;
    line-height: $height;
    text-align: center;
    i {
      font-size: 1.2rem;
    }
    &:active {
      background: #ddd;
    }
  }
  .left {
    left: 0;
  }
  .right {
    right: 0;
  }
  p {
    line-height: $height;
    text-align: center;
    font-size: 1.2rem;
  }
}
</style>